package com.loongtech.bi.action.report;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.loongtech.bi.action.BaseBiSearchAction;
import com.loongtech.bi.manager.system.SysLogManager;
import com.loongtech.bi.support.Session;
import com.loongtech.bi.support.chart.ChartData1;
import com.loongtech.bi.support.chart.ChartFlow;
import com.loongtech.bi.support.chart.ChartSelect;
import com.loongtech.bi.support.chart.ChartTool;
import com.loongtech.bi.support.chart.ChartType;

/**
 * Report Action
 * @author Marin
 * @date 2015年09月17日
 */
@Controller
@Scope("view")
public class ReportAction extends BaseBiSearchAction {
	private static final long serialVersionUID = 1L;
	private List<OverAll> overAllList = new ArrayList<OverAll>();  // 数据库中查询出来的符合查询条件的所有对象
	private List<OverAll> overAllAllList = new ArrayList<OverAll>();  // 根据overAllList组装出来的供前端显示的总体数据
	private List<OverAll> overAllPlatformList = new ArrayList<OverAll>();  // 根据overAllList组装出来的供前端显示的平台数据
	private List<OverAll> overAllChannelList = new ArrayList<OverAll>();  // 根据overAllList组装出来的供前端显示的渠道数据
	private List<OverAll> overAllServerList = new ArrayList<OverAll>();  // 根据overAllList组装出来的供前端显示的区服数据
	private List<ChartTmp> chartList = new ArrayList<ChartTmp>();  // 根据overAllList组装出来的供前端显示的三个饼状图数据
	private List<OverAllChannelChart> overAllChannelChartList = new ArrayList<OverAllChannelChart>();  // 根据overAllList组装出来的前端曲线图所有数据
	private String selectItem = "";					// 前端选择的要显示曲线图数据的列
	private LinkedHashMap<String, String> allItmes;	// 前端可选择的曲线图数据的所有的列
	private String jsonChartData;  // 前端曲线图数据
	private String chartType = ChartType.SPLINE.type;  // 曲线图类型（spline=线状图，area=区域图，pie=饼状图，column=柱状）
	
	@Autowired
	private SysLogManager sysLogManager;
	@Autowired
	private Session session;
	
	@PostConstruct
	public void init() {
		allItmes = ChartTool.getAllItems(OverAllChannelChart.class);  // 初始化曲线图数据可选列
		search();
	}

	public void search() {
		sysLogManager.addLog(session.getUserName(), "查询Report Action");
		
		overAllList.clear();
		overAllAllList.clear();
		overAllPlatformList.clear();
		overAllChannelList.clear();
		overAllServerList.clear();
		jsonChartData = null;
		chartList.clear();
		overAllChannelChartList.clear();
		
		// TODO 这里先假设几个数据，真实情况下，应该是从数据库里取
		for (int i = 0; i < 100; i++) {
			int add = i * 100 + 3;
			OverAll oa = new OverAll();
			oa.setPlatformId(i % 2 + 1 + "");
			oa.setServerId(i % 2 + 1 + "");
			if (i < 25) {
				oa.setChannelId(1 + "");
			} else if (i < 50) {
				oa.setChannelId(2 + "");
			} else if (i < 75) {
				oa.setChannelId(3 + "");
			} else {
				oa.setChannelId(4 + "");
			}
			oa.setDateStr("2015-09-1" + i % 10);
			oa.setNewDevice(8 + add);
			oa.setNewRole(3 + add);
			oa.setNewUser(9 + add);
			oa.setThe2Left((float)(0.02 + i * 0.1));
			oa.setThe3Left((float)(0.03 + i * 0.1));
			oa.setThe7Left((float)(0.04 + i * 0.1));
			oa.setDau(40 + add);
			oa.setPcu(50 + add);
			oa.setAcu(60 + add);
			oa.setAvgOnlineTime(1000 + add);
			oa.setEffectiveNewUser(19 + add);
			oa.setEffectiveNewUserLogin(222 + add);
			oa.setLeftUserLogin(77 + add);
			oa.setLoginProportion((float)(0.09 + i * 0.2));
			oa.setCostUser(88 + add);
			oa.setCostYuanbao(9999 + add);
			overAllList.add(oa);
		}
		
		// 下面是根据overAllList组装前端显示所需的数据
		OverAll oall = new OverAll();  // 总体数据
		Map<String, List<OverAll>> tmp1 = new HashMap<String, List<OverAll>>();  // 平台
		Map<String, List<OverAll>> tmp2 = new HashMap<String, List<OverAll>>();  // 渠道
		Map<String, List<OverAll>> tmp3 = new HashMap<String, List<OverAll>>();  // 区服
		Map<String, List<OverAll>> tmp4 = new HashMap<String, List<OverAll>>();  // 曲线图
		for (OverAll oa : overAllList) {
			// 总体数据是所有都加在一起
			oall.setNewDevice(oa.getNewDevice() + oall.getNewDevice());
			oall.setNewRole(oa.getNewRole() + oall.getNewRole());
			oall.setNewUser(oa.getNewUser() + oall.getNewUser());
			oall.setThe2Left((float)(Math.round((oa.getThe2Left() + oall.getThe2Left()) * 100) / 100));
			oall.setThe3Left((float)(Math.round((oa.getThe3Left() + oall.getThe3Left()) * 100) / 100));
			oall.setThe7Left((float)(Math.round((oa.getThe7Left() + oall.getThe7Left()) * 100) / 100));
			oall.setDau(oa.getDau() + oall.getDau());
			oall.setPcu(oa.getPcu() + oall.getPcu());
			oall.setAcu(oa.getAcu() + oall.getAcu());
			oall.setAvgOnlineTime(oa.getAvgOnlineTime() + oall.getAvgOnlineTime());
			oall.setEffectiveNewUser(oa.getEffectiveNewUser() + oall.getEffectiveNewUser());
			oall.setEffectiveNewUserLogin(oa.getEffectiveNewUserLogin() + oall.getEffectiveNewUserLogin());
			oall.setLeftUserLogin(oa.getLeftUserLogin() + oall.getLeftUserLogin());
			oall.setLoginProportion((float)(Math.round((oa.getLoginProportion() + oall.getLeftUserLogin()) * 100) / 100));
			oall.setCostUser(oa.getCostUser() + oall.getCostUser());
			oall.setCostYuanbao(oa.getCostYuanbao() + oall.getCostYuanbao());
			
			// 平台数据是日期相同的加一起
			List<OverAll> oal1 = tmp1.get(oa.getDateStr());
			if (oal1 == null) {
				oal1 = new ArrayList<OverAll>();
				tmp1.put(oa.getDateStr(), oal1);
			}
			oal1.add(oa);
			
			// 渠道数据是渠道相同的加一起
			List<OverAll> oal2 = tmp2.get(oa.getChannelId());
			if (oal2 == null) {
				oal2 = new ArrayList<OverAll>();
				tmp2.put(oa.getChannelId(), oal2);
			}
			oal2.add(oa);
			
			// 区服数据是区服相同的加一起
			List<OverAll> oal3 = tmp3.get(oa.getServerId());
			if (oal3 == null) {
				oal3 = new ArrayList<OverAll>();
				tmp3.put(oa.getServerId(), oal3);
			}
			oal3.add(oa);
			
			// 曲线图是日期和渠道相同的加一起
			List<OverAll> oal4 = tmp4.get(oa.getDateStr() + "@" + oa.getChannelId());
			if (oal4 == null) {
				oal4 = new ArrayList<OverAll>();
				tmp4.put(oa.getDateStr() + "@" + oa.getChannelId(), oal4);
			}
			oal4.add(oa);
		}
		
		// 组装供前端展示的总体数据
		overAllAllList.add(oall);
		// 组装供前端展示的平台数据
		for (Entry<String, List<OverAll>> entry : tmp1.entrySet()) {
			List<OverAll> value = entry.getValue();
			OverAll oa = new OverAll();
			oa.setDateStr(entry.getKey());
			for (OverAll o : value) {
				oa.setNewDevice(oa.getNewDevice() + o.getNewDevice());
				oa.setNewRole(oa.getNewRole() + o.getNewRole());
				oa.setNewUser(oa.getNewUser() + o.getNewUser());
				oa.setThe2Left((float)(Math.round((oa.getThe2Left() + o.getThe2Left()) * 100) / 100));
				oa.setThe3Left((float)(Math.round((oa.getThe3Left() + o.getThe3Left()) * 100) / 100));
				oa.setThe7Left((float)(Math.round((oa.getThe7Left() + o.getThe7Left()) * 100) / 100));
				oa.setDau(oa.getDau() + o.getDau());
				oa.setPcu(oa.getPcu() + o.getPcu());
				oa.setAcu(oa.getAcu() + o.getAcu());
				oa.setAvgOnlineTime(oa.getAvgOnlineTime() + o.getAvgOnlineTime());
				oa.setEffectiveNewUser(oa.getEffectiveNewUser() + o.getEffectiveNewUser());
				oa.setEffectiveNewUserLogin(oa.getEffectiveNewUserLogin() + o.getEffectiveNewUserLogin());
				oa.setLeftUserLogin(oa.getLeftUserLogin() + o.getLeftUserLogin());
				oa.setLoginProportion((float)(Math.round((oa.getLoginProportion() + o.getLeftUserLogin()) * 100) / 100));
				oa.setCostUser(oa.getCostUser() + o.getCostUser());
				oa.setCostYuanbao(oa.getCostYuanbao() + o.getCostYuanbao());
			}
			overAllPlatformList.add(oa);
		}
		// 组装供前端展示的曲线图数据
		for (Entry<String, List<OverAll>> entry : tmp4.entrySet()) {
			String ds = entry.getKey().split("@")[0];
			String cid = entry.getKey().split("@")[1];
			List<OverAll> value = entry.getValue();
			OverAllChannelChart oa = new OverAllChannelChart();
			oa.setDateStr(ds);
			oa.setChannelId(cid);
			for (OverAll o : value) {
				oa.setNewDevice(oa.getNewDevice() + o.getNewDevice());
				oa.setNewRole(oa.getNewRole() + o.getNewRole());
				oa.setNewUser(oa.getNewUser() + o.getNewUser());
				oa.setThe2Left((float)(Math.round((oa.getThe2Left() + o.getThe2Left()) * 100) / 100));
				oa.setThe3Left((float)(Math.round((oa.getThe3Left() + o.getThe3Left()) * 100) / 100));
				oa.setThe7Left((float)(Math.round((oa.getThe7Left() + o.getThe7Left()) * 100) / 100));
				oa.setDau(oa.getDau() + o.getDau());
				oa.setPcu(oa.getPcu() + o.getPcu());
				oa.setAcu(oa.getAcu() + o.getAcu());
				oa.setAvgOnlineTime(oa.getAvgOnlineTime() + o.getAvgOnlineTime());
				oa.setEffectiveNewUser(oa.getEffectiveNewUser() + o.getEffectiveNewUser());
				oa.setEffectiveNewUserLogin(oa.getEffectiveNewUserLogin() + o.getEffectiveNewUserLogin());
				oa.setLeftUserLogin(oa.getLeftUserLogin() + o.getLeftUserLogin());
				oa.setLoginProportion((float)(Math.round((oa.getLoginProportion() + o.getLeftUserLogin()) * 100) / 100));
				oa.setCostUser(oa.getCostUser() + o.getCostUser());
				oa.setCostYuanbao(oa.getCostYuanbao() + o.getCostYuanbao());
			}
			overAllChannelChartList.add(oa);
		}
		// 组装供前端展示的渠道数据
		for (Entry<String, List<OverAll>> entry : tmp2.entrySet()) {
			List<OverAll> value = entry.getValue();	
			OverAll oa = new OverAll();
			oa.setChannelId(entry.getKey());
			for (OverAll o : value) {
				oa.setNewDevice(oa.getNewDevice() + o.getNewDevice());
				oa.setNewRole(oa.getNewRole() + o.getNewRole());
				oa.setNewUser(oa.getNewUser() + o.getNewUser());
				oa.setThe2Left((float)(Math.round((oa.getThe2Left() + o.getThe2Left()) * 100) / 100));
				oa.setThe3Left((float)(Math.round((oa.getThe3Left() + o.getThe3Left()) * 100) / 100));
				oa.setThe7Left((float)(Math.round((oa.getThe7Left() + o.getThe7Left()) * 100) / 100));
				oa.setDau(oa.getDau() + o.getDau());
				oa.setPcu(oa.getPcu() + o.getPcu());
				oa.setAcu(oa.getAcu() + o.getAcu());
				oa.setAvgOnlineTime(oa.getAvgOnlineTime() + o.getAvgOnlineTime());
				oa.setEffectiveNewUser(oa.getEffectiveNewUser() + o.getEffectiveNewUser());
				oa.setEffectiveNewUserLogin(oa.getEffectiveNewUserLogin() + o.getEffectiveNewUserLogin());
				oa.setLeftUserLogin(oa.getLeftUserLogin() + o.getLeftUserLogin());
				oa.setLoginProportion((float)(Math.round((oa.getLoginProportion() + o.getLeftUserLogin()) * 100) / 100));
				oa.setCostUser(oa.getCostUser() + o.getCostUser());
				oa.setCostYuanbao(oa.getCostYuanbao() + o.getCostYuanbao());
			}
			overAllChannelList.add(oa);
		}
		// 组装供前端展示的区服数据
		for (Entry<String, List<OverAll>> entry : tmp3.entrySet()) {
			List<OverAll> value = entry.getValue();
			OverAll oa = new OverAll();
			oa.setServerId(entry.getKey());
			for (OverAll o : value) {
				oa.setNewDevice(oa.getNewDevice() + o.getNewDevice());
				oa.setNewRole(oa.getNewRole() + o.getNewRole());
				oa.setNewUser(oa.getNewUser() + o.getNewUser());
				oa.setThe2Left((float)(Math.round((oa.getThe2Left() + o.getThe2Left()) * 100) / 100));
				oa.setThe3Left((float)(Math.round((oa.getThe3Left() + o.getThe3Left()) * 100) / 100));
				oa.setThe7Left((float)(Math.round((oa.getThe7Left() + o.getThe7Left()) * 100) / 100));
				oa.setDau(oa.getDau() + o.getDau());
				oa.setPcu(oa.getPcu() + o.getPcu());
				oa.setAcu(oa.getAcu() + o.getAcu());
				oa.setAvgOnlineTime(oa.getAvgOnlineTime() + o.getAvgOnlineTime());
				oa.setEffectiveNewUser(oa.getEffectiveNewUser() + o.getEffectiveNewUser());
				oa.setEffectiveNewUserLogin(oa.getEffectiveNewUserLogin() + o.getEffectiveNewUserLogin());
				oa.setLeftUserLogin(oa.getLeftUserLogin() + o.getLeftUserLogin());
				oa.setLoginProportion((float)(Math.round((oa.getLoginProportion() + o.getLeftUserLogin()) * 100) / 100));
				oa.setCostUser(oa.getCostUser() + o.getCostUser());
				oa.setCostYuanbao(oa.getCostYuanbao() + o.getCostYuanbao());
			}
			overAllServerList.add(oa);
		}
		
		// 生成前端曲线图数据
		if (overAllChannelChartList != null && overAllChannelChartList.size() > 0) {
			jsonChartData = new ChartTool(overAllChannelChartList, OverAllChannelChart.class, selectItem).loadData(chartType);
		}
		
		// 生成前端三个饼状图数据
		for (int i = 1; i <= 3; i++) {
			ChartTmp ct = new ChartTmp();
			ct.setJsId(i + "");
			ct.setJsonStr(new ChartTool(overAllChannelList, OverAll.class, i == 1 ? "newUser" : (i == 2 ? "dau" : "costUser")).loadData(ChartType.PIE.type));
			ct.setJsonType(ChartType.PIE.type);
			ct.setHeader(i == 1 ? "各渠道新增账号" : (i == 2 ? "各渠道活跃账号" : "各渠道收入（元宝）"));
			chartList.add(ct);
		}
	}
	
	// 响应前端曲线图改变选择项事件
	public void handleDateChange() throws Exception {
		jsonChartData = new ChartTool(overAllChannelChartList, OverAllChannelChart.class, selectItem).loadData(chartType);
	}
	
	// TODO 渠道ID与渠道名对应关系
	public static String getChannelName(String channelId) {
		String result = channelId;
		
		if ("1".equals(channelId)) {
			result = "百度";
		} else if ("2".equals(channelId)) {
			result = "360";
		} else if ("3".equals(channelId)) {
			result = "UC";
		} else if ("4".equals(channelId)) {
			result = "小米";
		}
		
		return result;
	}
	
	// TODO 区服ID与区服名对应关系
	public static String getServerName(String serverId) {
		String result = serverId;
		
		if ("1".equals(serverId)) {
			result = "仗剑天涯";
		} else if ("2".equals(serverId)) {
			result = "称霸武林";
		}
		
		return result;
	}
	
	// 饼状图内部类
	public class ChartTmp {
		private String jsId;  // 第几个饼状图，前端图表的id是根据这个生成的，方便图表js操作这个id
		private String jsonStr;  // highcharts需要的json串
		private String jsonType;  // 图表类型
		private String header;  // 图表表头
		public String getJsId() {
			return jsId;
		}
		public void setJsId(String jsId) {
			this.jsId = jsId;
		}
		public String getJsonStr() {
			return jsonStr;
		}
		public void setJsonStr(String jsonStr) {
			this.jsonStr = jsonStr;
		}
		public String getJsonType() {
			return jsonType;
		}
		public void setJsonType(String jsonType) {
			this.jsonType = jsonType;
		}
		public String getHeader() {
			return header;
		}
		public void setHeader(String header) {
			this.header = header;
		}
	}
	
	// TODO 真实情况应该是数据库实体类。这里也做为饼状图的数据类
	public class OverAll {
		private String platformId;
		
		private String channelId;
		private String serverId;
		@ChartFlow(name="渠道")
		private String channelName;
		
		private String dateStr;  // 日期
		private int newDevice; // 新增设备
		@ChartSelect(name="新增帐号", key = 1)
		@ChartData1(name="新增帐号", key = 1)
		private int newUser; // 新增玩家
		private int newRole; // 新增角色
		private float the2Left; // 次日留存
		private float the3Left; // 3日留存
		private float the7Left; // 7日留存
		@ChartSelect(name="活跃帐号", key = 2)
		@ChartData1(name="活跃帐号", key = 2)
		private int dau; // DAU
		private int pcu; // PCU
		private int acu; // ACU
		private long avgOnlineTime; // 人均在线时长
		private int effectiveNewUser; // 有效新增用户数
		private float effectiveNewUserLogin; // 登录比新增用户有效率
		private int leftUserLogin; // 登录比留存用户数
		private float loginProportion; // 登录比
		@ChartSelect(name="消耗人数", key = 3)
		@ChartData1(name="消耗人数", key = 3)
		private int costUser; // 消耗人数
		private long costYuanbao; // 消耗元宝数据
		
		public int getNewDevice() {
			return newDevice;
		}
		public void setNewDevice(int newDevice) {
			this.newDevice = newDevice;
		}
		public int getNewUser() {
			return newUser;
		}
		public void setNewUser(int newUser) {
			this.newUser = newUser;
		}
		public int getNewRole() {
			return newRole;
		}
		public void setNewRole(int newRole) {
			this.newRole = newRole;
		}
		public float getThe2Left() {
			return the2Left;
		}
		public void setThe2Left(float the2Left) {
			this.the2Left = the2Left;
		}
		public float getThe3Left() {
			return the3Left;
		}
		public void setThe3Left(float the3Left) {
			this.the3Left = the3Left;
		}
		public float getThe7Left() {
			return the7Left;
		}
		public void setThe7Left(float the7Left) {
			this.the7Left = the7Left;
		}
		public int getDau() {
			return dau;
		}
		public void setDau(int dau) {
			this.dau = dau;
		}
		public int getPcu() {
			return pcu;
		}
		public void setPcu(int pcu) {
			this.pcu = pcu;
		}
		public int getAcu() {
			return acu;
		}
		public void setAcu(int acu) {
			this.acu = acu;
		}
		public long getAvgOnlineTime() {
			return avgOnlineTime;
		}
		public void setAvgOnlineTime(long avgOnlineTime) {
			this.avgOnlineTime = avgOnlineTime;
		}
		public int getEffectiveNewUser() {
			return effectiveNewUser;
		}
		public void setEffectiveNewUser(int effectiveNewUser) {
			this.effectiveNewUser = effectiveNewUser;
		}
		public float getEffectiveNewUserLogin() {
			return effectiveNewUserLogin;
		}
		public void setEffectiveNewUserLogin(float effectiveNewUserLogin) {
			this.effectiveNewUserLogin = effectiveNewUserLogin;
		}
		public int getLeftUserLogin() {
			return leftUserLogin;
		}
		public void setLeftUserLogin(int leftUserLogin) {
			this.leftUserLogin = leftUserLogin;
		}
		public float getLoginProportion() {
			return loginProportion;
		}
		public void setLoginProportion(float loginProportion) {
			this.loginProportion = loginProportion;
		}
		public int getCostUser() {
			return costUser;
		}
		public void setCostUser(int costUser) {
			this.costUser = costUser;
		}
		public long getCostYuanbao() {
			return costYuanbao;
		}
		public void setCostYuanbao(long costYuanbao) {
			this.costYuanbao = costYuanbao;
		}
		public String getDateStr() {
			return dateStr;
		}
		public void setDateStr(String dateStr) {
			this.dateStr = dateStr;
		}
		public String getPlatformId() {
			return platformId;
		}
		public void setPlatformId(String platformId) {
			this.platformId = platformId;
		}
		public String getChannelId() {
			return channelId;
		}
		public void setChannelId(String channelId) {
			this.channelId = channelId;
			this.channelName = ReportAction.getChannelName(channelId);
		}
		public String getServerId() {
			return serverId;
		}
		public void setServerId(String serverId) {
			this.serverId = serverId;
		}
		public String getChannelName() {
			return channelName;
		}
		public void setChannelName(String channelName) {
			this.channelName = channelName;
		}
	}
	
	// TODO 这个曲线图比较特殊，要根据渠道名称的不同，画出多个曲线，而前面的饼状图没有这个需求，所以OverAll类被饼状图用了，这里另写一个曲线图用的图表数据类
	public class OverAllChannelChart {
		private String channelId;
		private String channelName;
		@ChartFlow(name="日期")
		private String dateStr;  // 日期
		private int newDevice; // 新增设备
		@ChartSelect(name="新增帐号", key = 1)
		@ChartData1(name="新增帐号", key = 1, multiByFiled="channelName")
		private int newUser; // 新增玩家
		private int newRole; // 新增角色
		private float the2Left; // 次日留存
		private float the3Left; // 3日留存
		private float the7Left; // 7日留存
		@ChartSelect(name="活跃帐号", key = 2)
		@ChartData1(name="活跃帐号", key = 2, multiByFiled="channelName")
		private int dau; // DAU
		private int pcu; // PCU
		private int acu; // ACU
		private long avgOnlineTime; // 人均在线时长
		private int effectiveNewUser; // 有效新增用户数
		private float effectiveNewUserLogin; // 登录比新增用户有效率
		private int leftUserLogin; // 登录比留存用户数
		private float loginProportion; // 登录比
		@ChartSelect(name="消耗人数", key = 3)
		@ChartData1(name="消耗人数", key = 3, multiByFiled="channelName")
		private int costUser; // 消耗人数
		private long costYuanbao; // 消耗元宝数据
		
		public int getNewDevice() {
			return newDevice;
		}
		public void setNewDevice(int newDevice) {
			this.newDevice = newDevice;
		}
		public int getNewUser() {
			return newUser;
		}
		public void setNewUser(int newUser) {
			this.newUser = newUser;
		}
		public int getNewRole() {
			return newRole;
		}
		public void setNewRole(int newRole) {
			this.newRole = newRole;
		}
		public float getThe2Left() {
			return the2Left;
		}
		public void setThe2Left(float the2Left) {
			this.the2Left = the2Left;
		}
		public float getThe3Left() {
			return the3Left;
		}
		public void setThe3Left(float the3Left) {
			this.the3Left = the3Left;
		}
		public float getThe7Left() {
			return the7Left;
		}
		public void setThe7Left(float the7Left) {
			this.the7Left = the7Left;
		}
		public int getDau() {
			return dau;
		}
		public void setDau(int dau) {
			this.dau = dau;
		}
		public int getPcu() {
			return pcu;
		}
		public void setPcu(int pcu) {
			this.pcu = pcu;
		}
		public int getAcu() {
			return acu;
		}
		public void setAcu(int acu) {
			this.acu = acu;
		}
		public long getAvgOnlineTime() {
			return avgOnlineTime;
		}
		public void setAvgOnlineTime(long avgOnlineTime) {
			this.avgOnlineTime = avgOnlineTime;
		}
		public int getEffectiveNewUser() {
			return effectiveNewUser;
		}
		public void setEffectiveNewUser(int effectiveNewUser) {
			this.effectiveNewUser = effectiveNewUser;
		}
		public float getEffectiveNewUserLogin() {
			return effectiveNewUserLogin;
		}
		public void setEffectiveNewUserLogin(float effectiveNewUserLogin) {
			this.effectiveNewUserLogin = effectiveNewUserLogin;
		}
		public int getLeftUserLogin() {
			return leftUserLogin;
		}
		public void setLeftUserLogin(int leftUserLogin) {
			this.leftUserLogin = leftUserLogin;
		}
		public float getLoginProportion() {
			return loginProportion;
		}
		public void setLoginProportion(float loginProportion) {
			this.loginProportion = loginProportion;
		}
		public int getCostUser() {
			return costUser;
		}
		public void setCostUser(int costUser) {
			this.costUser = costUser;
		}
		public long getCostYuanbao() {
			return costYuanbao;
		}
		public void setCostYuanbao(long costYuanbao) {
			this.costYuanbao = costYuanbao;
		}
		public String getDateStr() {
			return dateStr;
		}
		public void setDateStr(String dateStr) {
			this.dateStr = dateStr;
		}
		
		public String getChannelId() {
			return channelId;
		}
		public void setChannelId(String channelId) {
			this.channelId = channelId;
			this.channelName = ReportAction.getChannelName(channelId);
		}
		
		public String getChannelName() {
			return channelName;
		}
		public void setChannelName(String channelName) {
			this.channelName = channelName;
		}
	}

	@Override
	protected String csvContent() {
		StringBuffer sb = new StringBuffer();
		sb.append("日期").append(",");
		sb.append("日活跃DAU").append(",");
		sb.append("平均在线ACU").append(",");
		sb.append("最高在线PCU").append("\n");

		/*for(EntityOnlineData item : list) {
			sb.append(item.getDate()).append(",");
			sb.append(item.getDau()).append(",");
			sb.append(item.getAcu()).append(",");
			sb.append(item.getPcu()).append("\n");
		}*/

		return sb.toString();
	}

	@Override
    protected String csvFileName() {
	    return "运营日报";
    }
	
	public String getJsonChartData() {
		return jsonChartData;
	}

	public void setJsonChartData(String jsonChartData) {
		this.jsonChartData = jsonChartData;
	}

	public String getChartType() {
		return chartType;
	}

	public void setChartType(String chartType) {
		this.chartType = chartType;
	}
	
	public Date getDateStart() {
		return dateStart;
	}

	public void setDateStart(Date dateStart) {
		this.dateStart = dateStart;
	}

	public Date getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

	public List<OverAll> getOverAllList() {
		return overAllList;
	}

	public void setOverAllList(List<OverAll> overAllList) {
		this.overAllList = overAllList;
	}

	public List<OverAll> getOverAllPlatformList() {
		return overAllPlatformList;
	}

	public void setOverAllPlatformList(List<OverAll> overAllPlatformList) {
		this.overAllPlatformList = overAllPlatformList;
	}

	public List<OverAll> getOverAllChannelList() {
		return overAllChannelList;
	}

	public void setOverAllChannelList(List<OverAll> overAllChannelList) {
		this.overAllChannelList = overAllChannelList;
	}

	public List<OverAll> getOverAllServerList() {
		return overAllServerList;
	}

	public void setOverAllServerList(List<OverAll> overAllServerList) {
		this.overAllServerList = overAllServerList;
	}

	public List<OverAll> getOverAllAllList() {
		return overAllAllList;
	}

	public void setOverAllAllList(List<OverAll> overAllAllList) {
		this.overAllAllList = overAllAllList;
	}

	public List<ChartTmp> getChartList() {
		return chartList;
	}

	public void setChartList(List<ChartTmp> chartList) {
		this.chartList = chartList;
	}

	public String getSelectItem() {
		return selectItem;
	}

	public void setSelectItem(String selectItem) {
		this.selectItem = selectItem;
	}

	public LinkedHashMap<String, String> getAllItmes() {
		return allItmes;
	}

	public void setAllItmes(LinkedHashMap<String, String> allItmes) {
		this.allItmes = allItmes;
	}

	public String getQueryPlatform() {
		return queryPlatform;
	}

	public void setQueryPlatform(String queryPlatform) {
		this.queryPlatform = queryPlatform;
	}

	public String getQueryChannel() {
		return queryChannel;
	}

	public void setQueryChannel(String queryChannel) {
		this.queryChannel = queryChannel;
	}

	public String getQueryServer() {
		return queryServer;
	}

	public void setQueryServer(String queryServer) {
		this.queryServer = queryServer;
	}
}
